﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using NHibernate.Context;
using NServiceBus.Saga;
using NServiceBus;

using StructureMap.Pipeline;

namespace Subscriber1
{
    public static class Extensions
    {
        public static Configure SetSagaPersister(this NServiceBus.Configure config, StructureMap.IContainer container)
        {
            var args = new ExplicitArguments();
            var factory = container.GetInstance<ISessionFactory>("ISessionFactoryInstance");
            args.Set(typeof(ISessionFactory), factory);

            config.Configurer.RegisterSingleton(typeof(ISagaPersister), container.GetInstance<ISagaPersister>(args));
            return config;
        }
    }
}
